﻿using System;
using SmartContentModule.Helpers;

namespace SmartContentModule.CssModel
{
    internal class CssUrlInfo
    {
        private string url;
        private string directory;
        private string filepath;

        /// <summary>
        /// Constructor for CssUrlInfo
        /// </summary>
        /// <param name="url">url, such as ../../Images/sample.png</param>
        /// <param name="directory">Directory for content</param>
        public CssUrlInfo(string url, string directory)
        {
            if (url.Contains("\""))
                url = url.Replace("\"", String.Empty);
            if (url.Contains("'"))
                url = url.Replace("'", String.Empty);

            this.url = url;
            this.directory = directory;
            this.filepath = IOHelper.GetFilePath(ContentUrl, directory);
        }

        /// <summary>
        /// Gets content url
        /// </summary>
        internal string ContentUrl
        {
            get { return url; }
        }

        /// <summary>
        /// Gets file path
        /// </summary>
        internal string FilePath
        {
            get
            {
                return filepath;
            }
        }

        /// <summary>
        /// String representation of last modified time in format yyyyMMddHHmmss
        /// </summary>
        internal string LastModification
        {
            get
            {
                return IOHelper.GetLastModificationPostfix(FilePath);
            }
        }
    }
}
